#coding=utf8

import sys

caffe_root = '/home/chong/caffe/'
sys.path.insert(0, caffe_root + 'python')
import caffe

if __name__ == "__main__":
    #文件的存放路径
    root = '/home/chong/caffe/examples/mnist/'
    caffe.set_mode_gpu()

    net = caffe.Net(root + 'lenet.prototxt', root + 'lenet_iter_10000.caffemodel', caffe.TEST)
   #第一个卷基层的权值
    conv1_w = net.params['conv1'][0].data
    #第一个卷基层的偏置值
    conv1_b = net.params['conv1'][1].data
    #可以打印相应的参数和参数的维度等信息
    print conv1_w
    print conv1_b
    print conv1_w.shape, conv1_b.shape
    print conv1_w.size, conv1_b.size

    conv2_w = net.params['conv2'][0].data
    conv2_b = net.params['conv2'][1].data
    print conv2_w.shape, conv2_b.shape
    print conv2_w
    print conv2_b

    ip1_w = net.params['ip1'][0].data
    ip1_b = net.params['ip1'][1].data
    print ip1_w.shape, ip1_b.shape

    ip2_w = net.params['ip2'][0].data
    ip2_b = net.params['ip2'][1].data
    print ip2_w.shape, ip2_b.shape
    print ip2_w
    print ip2_b

    print 'conv1 shape:', net.params['conv1'][0].data.shape, net.params['conv1'][1].data.shape
    print 'conv2 shape:', net.params['conv2'][0].data.shape, net.params['conv2'][1].data.shape
    print 'ip1 shape:', net.params['ip1'][0].data.shape, net.params['ip1'][1].data.shape
    print 'ip2 shape:', net.params['ip2'][0].data.shape, net.params['ip2'][1].data.shape

